﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class du_an_khu_do_thi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                bindQuanHuyen();
                bindLoaiBDS();
            }
        }
        catch (Exception ex) { }
    }
    protected void bindQuanHuyen()
    {
        repQuanHuyen.DataSource = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(42)));
        repQuanHuyen.DataBind();
    }
    protected void bindLoaiBDS()
    {
        repLoaiBDS.DataSource = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(43)));
        repLoaiBDS.DataBind();
    }
    protected void repLoaiBDS_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        HiddenField hidLoaiID = (HiddenField)e.Item.FindControl("hidLoaiID");
        Repeater repLoaiBDSc = (Repeater)e.Item.FindControl("repLoaiBDSc");
        Label lblPager = (Label)e.Item.FindControl("lblPager");
        int loaiID=ConvertUtility.ToInt32(hidLoaiID.Value);
        Category_Info[] lstCat = Category_Info.getCatInDuAn(42,loaiID);
        
        repLoaiBDSc.DataSource = lstCat.Take(18);
        repLoaiBDSc.DataBind();
        int totalPage = (int)Math.Ceiling(ConvertUtility.ToDouble(lstCat.Length) / 18);
        lblPager.Text = ConvertUtility.buildSimplePaging(loaiID,totalPage, 18);
        
    }
  
}